<template>
  <div class="home">
    <el-container>
      <el-header height="80px">
        <el-row :gutter="20">
          <el-col :span="4"><img class="logo" src="../assets/logo.png" /></el-col>
          <el-col :span="16"><h2>后台界面</h2></el-col>
          <el-col :span="4"></el-col>
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            router
            active-text-color="#ffd04b"
            background-color="#545c64"
            class="el-menu-vertical-demo"
            default-active="2"
            text-color="#fff"
          >
            <el-menu-item v-for="item in list" :key="item.path" :index="item.path">
              <el-icon><icon-menu /></el-icon>
              <span>{{ item.meta.title }}</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <RouterView />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { useRouter } from 'vue-router'
export default defineComponent({
  name: 'HomeView',
  components: {
    // HelloWorld,
  },
  setup() {
    const router = useRouter()
    const list = router.getRoutes().filter((v) => v.meta.isChild)
    console.log(list)
    return { list }
  },
})
</script>

<style lang="scss" scoped>
.logo {
  height: 80px;
}
h2 {
  line-height: 80px;
  color: #fff;
  text-align: center;
}

.el-header {
  background-color: #545c64;
}
.el-aside {
  .el-menu {
    height: calc(100vh - 80px);
    overflow-y: auto;
  }
}
.el-main {
  height: calc(100vh - 80px);
  overflow-y: auto;
}
</style>
